#!/bin/bash

. common.sh 

unset LD_LIBRARY_PATH; #avoid any contamination when set!

if [ "${PREFIX}" = "" ]
then
	echo "Variable ${PREFIX} is not definied myabe an issue with . common.sh include"
	echo "Existing !!!"
	exit 1
fi    
	
echo "mv ${PREFIX} ${PREFIX}-old"
echo "Dont forget to mv ${PREFIX}-old ${PREFIX}"
mv ${PREFIX} ${PREFIX}-old

mkdir -p logs
echo "See $PWD/logs directory for details"
echo
echo "Starting compilation ....  $0"
echo

for file in `echo "dirac.sh schroedinger.sh yasm.sh a52dec.sh libao.sh opencore-amr.sh faac.sh libogg.sh faad.sh libtheora.sh xvid.sh libvorbis.sh libvpx.sh lame.sh x264-git.sh ffmpeg-git.sh "`
do
    #killall Console 2> /dev/null
    sleep 1
    #open -a Console logs/$file.log 
    SCRIPT=$file ; echo -n "Starting $SCRIPT : " ; bash ./video_tools_scripts/$SCRIPT > logs/$SCRIPT.log 2>&1 && echo " OK" || echo " failed (logs/$SCRIPT.log for details)"
done

echo
echo ""
exit

rm -rf /new_root_video_tools
mkdir -p /new_root_video_tools/usr/
mv ${PREFIX} /new_root_video_tools/usr/
mv ${PREFIX}-old ${PREFIX}

echo
echo
echo "See /new_root_video_tools for result !"
echo
